<%@ page language="java" pageEncoding="utf-8"%>
<%@taglib prefix="s" uri="/struts-tags"%>
${aier_doctype}
<html <s:property value="aier_html_xmlns" escape="false"/>>
<head>
<meta http-equiv="Content-Type" content="${aier_content_type}" />
<meta name="keywords" content="${aier_keyworks}" />
<meta name="description" content="${aier_description}" />
<title>${aier_title}</title>
<link rel="stylesheet" href="${aier_css_url}${aier_jqui_css}ui.css" />
<link rel="Stylesheet" href="${aier_css_url}jq/jq.css" />
<link rel="stylesheet" href="${aier_css_url}jc/chosen.css">
<link rel="stylesheet" href="${aier_css_url}social/module/jq-msg.css" />
<link rel="stylesheet" href="${aier_css_url}social/module/reset.css" />
<link rel="stylesheet" href="${aier_css_url}social/module/btn.css" />
<link rel="stylesheet"
	href="${aier_css_url}social/user/homeForums/common.css" />
<link rel="stylesheet" href="${aier_css_url}social/user/lookup.css" />


<script type="text/javascript" src="${aier_js_url}j.js"></script>
<script type="text/javascript" src="${aier_js_url}b.js"></script>
<script type="text/javascript" src="${aier_js_url}${aier_jqui_js}ui.js"></script>
<script type="text/javascript" src="${aier_js_url}97/WdatePicker.js"></script>
<script type="text/javascript" src="${aier_js_url}jp/msg.js"></script>
<script type="text/javascript" src="${aier_js_url}jq/cn.js"></script>
<script type="text/javascript" src="${aier_js_url}jq/jq.js"></script>
<script type="text/javascript" src="${aier_js_url}lib/ja.js"></script>
<script type="text/javascript" src="${aier_js_url}jc/cj.js"></script>
<script type="text/javascript" src="${aier_js_url}lib/block.js"></script>

</head>
<body>
	-
	<!-- 顶栏 -->
	<s:action name="userhomecomm_homeHead" namespace="/user"
		executeResult="true"></s:action>

	<div class="window-content">

		<!-- wrap  -->

		<div class="wrap wrap-homepage wrap-tri-col hasgap clearfix">

			<s:action name="userhomecomm_homeLeft" namespace="/user"
				executeResult="true"></s:action>

			<!-- 主区域 (右  -->
			<div class="main-area clearfix">

				<!-- 中间栏 -->
				<div class="message-stream">
					<div class="stream-main">
						<div class="right-main-top">
							<div class="binfo-title" id="title">
								<h3>找班级</h3>
							</div>
							<div class="right-line"></div>
						</div>

						<div class="searchCondition" id="condition">
							<div class="s_byaddres s_byaddres_class" >
								<div style="margin-bottom:40px;">学校所在地区：</div>
								<s:action name="citiesmap_cc" namespace="/common"
									executeResult="true"></s:action>
								<div class="s-school-class">
                                    <select id = "schoolList">
                                        
                                    </select>
                                </div>
							</div>
							<div class="s_byaddres s_byaddres_class" style="margin-top: 20px">
								<div class="s-name-class">
									<a id="fsBtn" href="javascript:;"
										class="button btn-loc">搜索</a>
								</div>

							</div>

						</div>



						<p class="result" style="" id="pResult">
							
						</p>


						<div class="resultList" id="resultList">
							
						</div>
					</div>
				</div>

				<!-- 右栏 -->
				<s:action name="userhomecomm_homeRight" namespace="/user"
					executeResult="true"></s:action>


			</div>
			<!-- 返回顶部 -->
			<s:action name="userhomecomm_backToTop" namespace="/user" executeResult="true"></s:action>
			<!-- end 返回顶部 -->
		</div>
		<!-- footer copyright -->
		<s:action name="userhomecomm_homeFooter" namespace="/user" executeResult="true"></s:action>
		<!-- /footer copyright -->
	</div>
</body>
<script type="text/javascript">
    $("#province").change(function() {
        searchSchoolByCid($("#province").val());
    });
    $("#city").change(function() {
        searchSchoolByCid($("#city").val());
    });
    $("#area").change(function() {
        searchSchoolByCid($("#area").val());
    });
    $("#street").change(function() {
        searchSchoolByCid($("#street").val());
    });
    // 根据城市id查询学校列表
    function searchSchoolByCid(cid) {
        $("#schoolList").html("");
        var fun=function(data){
            
            if(data.s==1){
                $("#schoolList").append("<option value='-1'>请选择 </option>");
                if (data.schoolList != null && data.schoolList.length > 0) {
                    
                    for ( var i = 0; i < data.schoolList.length; i++) {
                        $("#schoolList").append(
                                "<option value='"+data.schoolList[i].sid+"'>" + data.schoolList[i].name + "</option>");
                    }
                }
            }
        };
        exeAjax(
             ajaxUrl("${aier_url}${aier_urijs}lookup_searchSchoolByCid${aier_suffix}"),
             fun,{
                 "scid":cid
        });
    }
    //$("#schoolList").find("option:selected").text();
	
	//搜索
	$("#fsBtn").click(function() {
        
	    var sid = $("#schoolList").find("option:selected").val();
	    
	    if (sid == null || sid == -1) {
	       $().message("请选择学校！");
	       return;
	    }
	    var fun=function(data){
            
            if(data.s==1){
                appendClass(data.classList);
                
            } else {
                $().message("搜索失败，请稍后再试！");
            }
        };
        exeAjax(
             ajaxUrl("${aier_url}${aier_urijs}lookup_searchAllClasses${aier_suffix}"),
             fun,{
                 "sid":sid
        });
		
	});
	
	function appendClass(classList) {
	   var html = "";
	   if (classList != null && classList.length > 0) {
           $("#pResult").html('系统为您检索到 <span id="resultCount">'+classList.length+'<b>+</b> </span> 个结果');
           
           for (var i=0;i<classList.length;i++) {
               var cl = classList[i];
               html += '<div class="attent clearfix"><a href="${aier_url}classes/classeshome_classHomePage${aier_suffix}?cid='+cl.cid+'"><img alt='+cl.cname+' width="40" height="40" src="${classlogo_get_url}small/'+cl.clogo+'"></a><div>';
               html += '<a href="${aier_url}classes/classeshome_classHomePage${aier_suffix}?cid='+cl.cid+'"><font style="color:#c00000;">'+cl.cname+'</font></a>';
               if (!isnull(cl.manifesto)) {
                   html += '<p class="att">'+cl.manifesto+'</p>';
               }
               html += '<p></p></div></div>';
           }
           
       } else {
           $("#pResult").html('系统为您检索到 <span id="resultCount">0<b>+</b> </span> 个结果');
       }
       $("#resultList").html(html);
	}
	
	
</script>
</html>